<template>

<div class="container">
  <meta name="referrer" content="no-referrer" />
  <div class="userinfo-square">
    <div class="userinfo-header">
      <div class="avatar-grid">
        <avatar></avatar>
      </div>
      <div class="userinfo-name">
        <span class="name">{{userInfo.nick_name}}</span>
      </div>
      <div class="userinfo-level">
        <div class="third-party-fills">
          <img src="../assets/b_logo.png" style="height: 20px;width: 20px; margin-right: 5px; margin-bottom: 5px" v-show="userInfo.bid !== ''">
          <img src="../assets/netease-cloud-music-fill.png" style="height: 23px; width:23px; margin-bottom: 5px" v-show="userInfo.NetCloudId !== ''">
          <div class="level-badge">
            <span class="level">LV 2</span>
          </div>
        </div>

      </div>
      <!-- <div class="user-signature">
        这是我的个性签名....
      </div> -->
    </div>
    <div class="userinfo-selector">
      <!-- <div class="selector-name" :click="choose">个人信息</div>
      <div class="selector-name">发布的作品</div>
      <div class="selector-name">下载历史</div>
      <div class="selector-name">收藏</div> -->
      <div v-for="t in manueList" @click="choose(t)" :class="manue === t ? 'menu-div menu-choose' : 'menu-div menu-nochoose'" :key="t">{{t}} </div>
    </div>
    <hr class="split-line"/>
    <UserInfoEdit v-if="this.manue === '个人信息'"></UserInfoEdit>
    <UserProjects v-if="this.manue === '发布的作品'"></UserProjects>
    </div>
  </div>

</template>

<script>
import  Avatar from '@/components/Avatar'
import UserInfoEdit from '@/components/UserInfoEdit'
import UserProjects from '@/components/UserProjects'
export default {
  name: "UserInfo",
  components: {
    Avatar,
    UserInfoEdit,
    UserProjects,
  },

  data() {
    return {
      userInfo: {},
      manue: "个人信息",
      InfoEdit: true,
      Project: false,
      History: false,
      Collection: false,
      manueList: ["个人信息", "发布的作品", "下载历史", "收藏"]
    }
  },
  mounted() {
    this.userInfo = JSON.parse(localStorage.getItem("user"))
    if (this.userInfo === null) {
      alert("请登陆")
       this.$router.push('/')
    }
  },
  methods: {
      choose: function (t) {
        this.manue = t;
    }
  }

}
</script>

<style scoped>
.split-line {
  margin-top: -5px;
  border: 4px solid #CDC7C7;
  box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.3);
}

.userinfo-selector {
  width: 100%;
  height: 40px;
  display: flex;
  
  justify-items: center;
  align-items: center;
}
/* .userinfo-selector:hover {
    cursor: pointer;
} */
.menu-nochoose {
  text-align: center;
  font-family: PingFang, sans-serif;
  font-size: 22px;
  font-weight: normal;
  line-height: 34px;
  letter-spacing: 0em;
  color: #959595;
  flex-grow: 1;
  /*text-align: center;*/
}
.menu-nochoose:hover {
  cursor: pointer;
}
.menu-choose:hover {
  cursor: pointer;
}
.menu-choose {
  text-align: center;
  font-family: PingFang, sans-serif;
  font-size: 22px;
  font-weight: normal;
  line-height: 34px;
  letter-spacing: 0em;
  color: #000000;
  /*border-bottom: 4px solid #634E4E;*/
  flex-grow: 1;
}
.selector-name {
  align-self: center;
  justify-self: center;
  height: 30px;
  font-family: pingfang, sans-serif;
  font-size: 18px;
  font-weight: 500;
  line-height: 34px;
  letter-spacing: 0em;
  color: #B8B8B8;
}
.selector-name:hover {
   cursor: pointer;
   color: #95469F;
 }

.userinfo-square {
  margin: 10px auto;
  width: 80%;
  height: 605.38px;
  border-radius: 12px;
  background: #FFFFFF;
  box-sizing: border-box;

  /*border: 1px solid #C2C2C2;*/
}

.userinfo-header {
  width: 100%;
  height: 100px;
  display: grid;
  grid-template-columns: 100px 100px 1fr;
  grid-template-rows: 1fr 1fr;
  justify-items: center;
  align-items: center;
}
.userinfo-name {
  grid-column-start: 2;
  grid-column-end: 4;
  grid-row-start: 1;
  grid-row-end: 2;
  align-self: end;
  justify-self: start;
  font-family: HarmonyOS_Sans_SC_Black;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0em;
  color: #000000;
  margin-left: 5px;

}
.avatar-grid{
  grid-column-start: 1;
  grid-column-end: 2;
  grid-row-start: 1;
  grid-row-end: 3;
  align-self: end;
}

.userinfo-level {
  grid-column-start: 2;
  grid-row-start: 2;
  align-self: end;
  justify-self: start;
  margin-left: 5px;
}
.level-badge {
  width: 50px;
  height: 25px;
  border-radius: 11px;
  background: #5A5555;
  text-align: center;
  margin-right: 2px;
  margin-left: 2px
}
.level {
  font-family: HarmonyOS_Sans_SC_Black;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0em;
  color: #FFFFFF;
}
.third-party-fills {
  margin-left: 2px;
  margin-right: 2px;
  display: flex;
}

.user-signature {
  grid-row-start: 2;
  grid-row-end: 3;
  grid-column-start: 3;
  grid-column-end: 4;
  justify-self: start;
  align-self: end;
  height: 25px;
  border-radius: 8px;
  background: #DCD6D6;
  width: 200px;
  /*padding: 0 5px 0 5px;*/
  font-family: HarmonyOS_Sans_SC_Black;
  font-size: 10px;
  font-weight: 100;
  letter-spacing: 0em;
  text-align: left;
}

</style>